<?php
class Router {
	protected $reflect;
	public $object;
	public $result;

	public function __construct($controller) {
		try {
			$this->reflect = new ReflectionClass($controller . "Controller");
			$this->object = $this->reflect->newInstance();
		} catch (Exception $e) {
			exit("$controller is not exist err:".$e->getMessage());
		}
	}

	public function call($action, $params) {
		try {
			$relectMethod = $this->reflect->getMethod($action . "Action");
			$this->result = $relectMethod->invoke($this->object, $params);
		} catch(Exception $e) {
			exit("$action is not exist err:".$e->getMessage());
		}
		return $this->result;
	}

}